﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.UI.Bovespa.Corretagem.Communication.Bovespa.Corretagem.Desconto;
using Sinacor.Infra.UI.Common;

namespace Sinacor.UI.Bovespa.Corretagem.Communication.Translator.DataContractToModel
{

    //Task  : 5617 
    // Data : 16/03/2009
    // Autor:Apsilva
    /// <summary>
    /// Translator Desconto de Model para Data Contract
    /// </summary>
    /// 

    public class Desconto
    {

        #region Translate Conflito

        public Model.Conflito ToConflito(ConflitoResponse request)
        {
            Model.Conflito response = new Model.Conflito();
            response.ExisteConflito = request.ExisteConflito;
            response.PermiteAjuste = request.PermiteAjuste;
            return response;
        }

        public ModelCollection<Model.Conflito> ToConflito(List<ConflitoResponse> request)
        {
            ModelCollection<Model.Conflito> response = new ModelCollection<Model.Conflito>();
            foreach (ConflitoResponse item in request)
            {
                response.Add(ToConflito(item));
            }
            return response;
        }

        #endregion

        #region Translate Desconto

        public Model.Desconto ToDesconto(DescontoResponse request)
        {
            Model.Desconto response = new Model.Desconto();
            response.PercentualAllIn = request.PercentualAllIn;
            response.PercentualDescontoAcresimo = request.PercentualDescontoAcresimo;

            Model.Periodo periodo = new Model.Periodo();
            if (request.Periodo != null)
            {
                periodo.DataFinal = request.Periodo.DataFinal;
                periodo.DataInicial = request.Periodo.DataInicial;
            }
            response.Periodo = periodo;
            return response;
        }

        public ModelCollection<Model.Desconto> ToDesconto(List<DescontoResponse> request)
        {
            ModelCollection<Model.Desconto> response = new ModelCollection<Model.Desconto>();
            foreach (DescontoResponse item in request)
            {
                response.Add(ToDesconto(item));

            }
            return response;
        }

        #endregion

    }
}
